﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<brjostagjof.Models.Article>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Greinar bls. <%: ((ViewData["pageID"]) as int?).Value + 1%>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <a href="/Home/Greinar/" class="linksWhite">Til baka í greinar</a>
    <h2>Fleiri greinar:</h2>

       
        <%foreach (var item in Model)
        { %>
        <div class="entry">
        <div class="entry-bgtop">
        <div class="entry-bgbtm">
            <h2 class="title"><a href="<%: item.ArticleBase.link %><%: item.articleBaseID %>"><%: item.ArticleBase.InformationBase.headline%></a></h2>
            <p class="meta">Höfundur: <a href="../../MySite/ViewUserByID/<%:item.ArticleBase.User.ID  %>"><%: item.ArticleBase.User.name%></a>,  <%: item.ArticleBase.InformationBase.date%> 
	            &nbsp;&bull;&nbsp;
                <%  int count = brjostagjof.Controllers.HomeController.GetCommentsCountByArticleBaseID(item.articleBaseID); %>
                Umsagnir  (<%: count %>) &nbsp;&bull;&nbsp;  
                <a href="/Home/GetArticleByCategoryID/<%: item.ArticleBase.ArticleCategory.ID %>" class="permalink"> <%: item.ArticleBase.ArticleCategory.name %></a>
                &nbsp;&bull;&nbsp;
                <a href="<%: item.ArticleBase.link %><%: item.ArticleBase.informationBaseID %>" class="permalink">Öll grein</a></p>
        </div>
        </div>
        </div>
            <%  } %>
            <% int page = (ViewData["pageID"] as int?).Value; %>

            <%if(page==1)
              { %>
                    <a href="/Home/Greinar/" class="linksWhite">Nýrri greinar</a><a href="/Home/Get10ArticleByPageID/<%:page+1 %>" class="linksWhite">Eldri greinar</a>
            <% } %>

            <% if (page != 1)
               { %>
                    <a href="/Home/Get10ArticleByPageID/<%:page-1 %>" class="linksWhite">Nýrri greinar</a>
            <% } %>

            <%if ((page <= (((brjostagjof.Controllers.HomeController.GetAllArticleCount())/10)-1))&& page!=1)
              { %>
                    <a href="/Home/Get10ArticleByPageID/<%:page+1 %>" class="linksWhite">Eldri greinar</a>
            <% } %>

            
            <% for (int i = page-4; i < page+5; i++)
            {%>
                <% if(i == 0)
                   { %>
                   <a href="/Home/Greinar/">1</a>    
                   <% }%>

                    <%if (page == i)
                      {%>
                        <a class="colorMeBlack" href="/Home/Get10ArticleByPageID/<%: i %>"><%: i + 1%></a>
                    <%} 
                      else
                      {%>
                          <a href="/Home/Get10ArticleByPageID/<%: i %>"><%: i + 1%></a>
                      <%}%>
               <% }%>

           <%if ((page-1 > 0) && (page < ((brjostagjof.Controllers.HomeController.GetAllArticleCount())/10)))
              { %>
                    <a href="/Home/Get10ArticleByPageID/<%:page+1 %>" class="linksWhite">Eldri greinar</a>
            <% } %>

</asp:Content>
